package com.atguigu.seckill.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.session.web.http.CookieSerializer;
import org.springframework.session.web.http.DefaultCookieSerializer;

/**
 * @author kabuda
 * @create 2022-12-01 11:39
 */
@Configuration
public class GulimallSessionConfig {
    //设置cookie信息
    @Bean
    public CookieSerializer cookieSerializer(){
        DefaultCookieSerializer defaultCookieSerializer = new DefaultCookieSerializer();
        defaultCookieSerializer.setCookieName("GULISESSION");
        defaultCookieSerializer.setDomainName("gulimall.com");
        return defaultCookieSerializer;
    }

    //设置redis序列化
    @Bean
    public RedisSerializer springSessionDefaultRedisSerializer(){
        //json序列化
        return new GenericJackson2JsonRedisSerializer();
    }

}
